package org.framework.lazy.cloud.network.heartbeat.protocol.auth;

import org.framework.lazy.cloud.network.heartbeat.protocol.properties.ProtocolProxyProperties;

public abstract class AbstractNettyPasswordAuth implements NettyPasswordAuth {

    private final ProtocolProxyProperties protocolProxyProperties;

    protected AbstractNettyPasswordAuth(ProtocolProxyProperties protocolProxyProperties) {
        this.protocolProxyProperties = protocolProxyProperties;
    }

    public abstract boolean doVerify(String username, String password);

    /**
     * 验证账号密码
     *
     * @param username 用户
     * @param password 密码
     * @return
     */
    @Override
    public boolean verify(String username, String password) {
        if (protocolProxyProperties.getAuthentication()) {
            return doVerify(username, password);
        }
        return true;
    }
}
